package com.neusoft.elmboot.controller;

import com.neusoft.elmboot.po.Orders;
import com.neusoft.elmboot.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author：ljz
 * @Date：2022/9/12 13:28
 * @Description:
 */
@RestController
@RequestMapping("/Orders")
public class OrdersController {
    @Autowired

    private OrdersService ordersService;

    @PostMapping("/OrdersId")
    public int createOrders(Orders orders) throws Exception {
        return ordersService.createOrders(orders);
    }

    @GetMapping("/OrdersId")
    public Orders getOrderById(Orders orders) throws Exception {
        return ordersService.getOrdersById(orders.getOrderId());
    }

    @GetMapping("/UserId")
    public List<Orders> listOrdersByUserId(Orders orders) throws Exception {
        return ordersService.listOrdersByUserId(orders.getUserId());
    }
}